package com.common.frame.decoration

import android.graphics.Canvas
import android.graphics.Rect
import android.view.View
import androidx.recyclerview.widget.RecyclerView

/**
 *
 * create by sunxy on 2020/8/20
 **/
class VerticalDecoration @JvmOverloads constructor(
    private val itemSpace:Int = 0, private val topSpace: Int = 0,
    private val leftSpace:Int = 0, private val rightSpace: Int = 0): BaseDecoration() {

    override fun onDraw(c: Canvas, parent: RecyclerView, state: RecyclerView.State) {}

    override fun getItemOffsets(
        outRect: Rect,
        view: View,
        parent: RecyclerView,
        state: RecyclerView.State
    ) {
        val pos = parent.getChildViewHolder(view).adapterPosition
        if (pos == 0){
            outRect.set(leftSpace, topSpace, rightSpace, itemSpace)
        }else{
            outRect.set(leftSpace, 0, rightSpace, itemSpace)
        }
    }
}